﻿using System;
using System.Collections;
using System.Collections.Generic;
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine;

public class SceneCameraComponent : MonoBehaviour
{
#if UNITY_EDITOR
    [NonSerialized]
    public bool CameraSpeedControl = true;
    [Range(0.1f,10f)]
    [NonSerialized]
    public float SceneCameraSpeedFactor = 1.0f;
    
    
    void Start()
    {
        
    }

    // Update is called once per frame
    void LateUpdate()
    {
        if (CameraSpeedControl)
        {
            SceneView sceneView = SceneView.lastActiveSceneView;
            sceneView.cameraSettings.speed = SceneCameraSpeedFactor * sceneView.camera.transform.position.y / 10f;
        }
    }


    private void OnValidate()
    {
        if (!CameraSpeedControl)
        {
            SceneView.lastActiveSceneView.ResetCameraSettings();
        }
    }
#endif
    

}
